Repository navigation
fix(id/currency_poc): refuse short create_transfers result vectors (#4669) - #6783
Merged
Merged
Conversation
Issue #4669: submit() zipped legs with results, so legs past the end of a short result vector were never examined and the record advanced to Posted unconditionally; recovery Resubmit scanned results for a failure entry, which an empty vector vacuously lacks. Require exactly one result per leg in both paths (submit bails and stays Submitted; Resubmit reports ResubmissionRejected and leaves the record unresolved), state the contract on the LedgerBackend::create_transfers doc, and cover both paths with a ShortResultBackend test double. currency_poc tests 50/50 on the laptop.
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 56 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Fixes issue #4669: neither the executor's submission path nor the recovery scanner checked that
LedgerBackend::create_transfersreturned one result per leg. A backend returning a short — or empty — result vector was treated as complete success and the conversion persisted asPostedwith nothing (or only part) in the ledger:submit()iteratedlegs.iter().zip(results.iter())(zip stops at the shorter side), and recovery'sResubmitpath scanned results for a failure entry, which an empty vector vacuously lacks. This is the result-vector side of the vacuous-success shape #4133 hardened for leg vectors. (Implements lane code-f's CONFIRMED triage on the issue.)Change (all in
pkgs/id/src/currency_poc/)executor.rs—submit()bails whenresults.len() != legs.len(), naming the conversion and both counts, before any per-leg verdict; the record staysSubmittedfor the recovery scanner.recovery.rs— theResubmitpath treats a short result vector as a rejected resubmission (ResubmissionRejected, record left unresolved, scan continues), neverPosted/Resubmitted.ledger.rs— thecreate_transferstrait doc now states the contract: exactly one result per submitted transfer, in submission order; any other length is a backend failure.tests.rs— aShortResultBackendtest double (reportskeepOk results, posts nothing, delegates lookups to a funded in-memory ledger) with two tests: submit with keep ∈ {0, 1, 2} errors naming the short vector and never advances pastSubmitted; recovery Resubmit with keep ∈ {0, 2} reportsResubmissionRejectedand leaves the recordRecorded.Verification
cargo test --lib currency_pocon the laptop: 50 passed, 0 failed (2 new).cargo fmt --checkclean on all four touched files.Fixes #4669.
Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.